import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
  let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
      let channel = FlutterMethodChannel(
        name: "native_utils",
        binaryMessenger: controller.binaryMessenger
      )

      channel.setMethodCallHandler({
        [weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
        switch call.method {
        case "setSecureScreen":
          // iOS无法真正阻止截屏，但可以监听截屏事件
          result(nil)
        case "isSecureScreen":
          // iOS总是返回false，因为没有真正的阻止方法
          result(false)
          case "checkRootOrJailbreak":
            let rootPlugin = RootDetectionPlugin()
            result(rootPlugin.checkRoot())
          default:
            result(FlutterMethodNotImplemented)
        }
      })
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
